/*
 * servidor.c
 *
 *  Created on: 30/10/2011
 *      Author: agustin
 */

#include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <errno.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <sys/wait.h>
    #include <signal.h>

#define DIRECCION_IP "192.168.1.103"

 int main(int argc, char **argv)
{
int server_sockfd;
int server_len;
struct sockaddr_in server_address;
struct sockaddr_in client_address;
char c[1024];

/* Crear un socket para el server */

server_sockfd = socket(AF_INET, SOCK_STREAM, 0);



/* nombre del socket */

server_address.sin_family = AF_INET;
server_address.sin_addr.s_addr = inet_addr(DIRECCION_IP) ;
server_address.sin_port = 9734;
server_len = sizeof(server_address) ;
bind(server_sockfd, (struct sockaddr *)&server_address, server_len) ;
listen(server_sockfd, 5);
printf("listen\n");
char str[50];
int n;

accept(server_sockfd,(struct sockaddr *)&server_address, &server_len);
printf("Connected\n");

n = recv(server_sockfd, str, 50, 0);
		if (str[0] == 'f')
			printf("apellido:jaite\n");
		if (n <= 0) {
			if (n < 0)
				perror("recv");
		}



close(server_sockfd);
return 0;
}
